var pageIndex;
$(function() {
	$("#FollowQuestionCategoryViewFrom").validate({
		rules : {
			'title' : {
			 	required:true
			},
			'content' : {
			 	required:true
			},
			'questionLevel' : {
			 	required:true
			},
			'status' : {
			 	required:true
			}
		},
		submitHandler : function(form) {
			if($("input[name='id']").val()=='' &&  $("input[name='File']").val()==''){
				$.warn("请上传图片");
				return ;
			}
			
			var options = {
				dataType : "json",
				success : function(data) {
					if (data.success) {
						$.success('操作成功', function() {
							layer.close(pageIndex);
							window.location.href = "getFollowQuestionCategoryList";
						});
					} else {
						$.error(data.msg);
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					$.warn('服务忙,请稍后再试.' + textStatus + errorThrown);
				}
			};
			$(form).ajaxSubmit(options);
		},
		invalidHandler : function(form, validator) {
			return false;
		}
	});

})

function countChar(textareaName,spanName)
{
document.getElementById(spanName).innerHTML = 1000 - document.getElementById(textareaName).value.length;
} 
